import 'package:flutter/material.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBNetConfig.dart';


enum Method {
  GET,
  POST,
  UPLOAD,
  DOWNLOAD,
}


class YBBaseNetWorkModule {
  static const _TAG = 'YBBaseNetWorkModule';

  get(String url, {Map<String, dynamic> params,BuildContext context,bool showLoad}) async {
    return;
  }

  getBaseUrl(){

  }


  static void printLog(String log, {tag}){
    bool print = isPrint();
    if (print) {
      String tagLog;
      if (tag != null) {
          tagLog = tag + log;
      } else{
        tagLog = log;
      }
      debugPrint(tagLog);
    }
  }

  static void printBigLog(String tag, String log){
    bool print = isPrint();
    const MAX_COUNT = 800;
    if (print) {
      if (log != null && log.length > MAX_COUNT) {
        // 超过1000就分次打印
        int len = log.length;
        int paragraphCount = ((len/MAX_COUNT) + 1).toInt();
        for(int i = 0; i < paragraphCount; i++){
          int printCount = MAX_COUNT;
          if (i == paragraphCount - 1) {
            printCount = len - (MAX_COUNT * (paragraphCount - 1));
          }
          String finalTag = '' + tag + '\n';
          printLog(log.substring(i * MAX_COUNT, i * MAX_COUNT + printCount) + '\n', tag: finalTag);
        }
      } else{
        String tagLog;
        if (tag == null) {
           tagLog = tag + log;
        } else{
           tagLog = log;
        }
        printLog(tagLog);
      }
    }
  }


  static bool isPrint(){
    return YBNetConfig.DEBUG;
  }

}